#ifndef MYCAMERA_H
#define MYCAMERA_H

#include <QWidget>
#include <QWidget>
#include <QMessageBox>
#include <QAudioInput>
#include <QCamera>
#include <QImageCapture>
#include <QMediaCaptureSession>
#include <QMediaDevices>
#include <QMediaMetaData>
#include <QMediaRecorder>
#include <QScopedPointer>
#include <qpermissions.h>
#include <QActionGroup>
#include <QVideoWidget>
#include <QVideoSink>
#include <QDebug>
#include <QMouseEvent>
#include <QTimer>
#include <opencvrenderthread.h>
#include <zbarrenderthread.h>

namespace Ui {
class MyCamera;
}

class MyCamera : public QWidget
{
    Q_OBJECT

public:
    explicit MyCamera(QWidget *parent = nullptr);
    ~MyCamera();
     void stopCamera();
     void startCamera();
     void CameraInit();
     void Pause(bool isPause);
 protected:
     bool QCameraInit();
     bool OpenCVCameraInit();

signals:
    void in_return_text(QString str);
//     void in_set_image(QImage image);

private slots:
     void on_comboBox_currentIndexChanged(int index);
     void in_video_frame(const QVideoFrame &frame);
     void in_get_barcode(QString str);
     void in_update_window(QImage image);

private:
    Ui::MyCamera *ui;
    int camera_id=-1;       // 相机标识（因为combobox控件在窗口创建的时候会回调一次change，所以需要标识来确认当前相机）
    // QCamera的
    QList<QCameraDevice> cameras;
    QCamera *m_camera= nullptr;
    QMediaCaptureSession m_captureSession;
    QVideoSink m_videoSink;
    ZbarRenderThread *m_zbar_thread=nullptr;            // // zbar Thread
    OpenCVRenderThread *m_opencv_cam_thread=nullptr;    // // OpenCV Camera Thread
};

#endif // MYCAMERA_H
